import java.io.PrintStream;
import java.util.List;

public class GameBoard {
    private List<String> positions;

    public GameBoard(List<String> positions){
        this.positions = positions;
    }

    public void drawBoard(PrintStream printStream) {
        printStream.println(this.format());
    }

    public void addAt(int index, String symbol) {
        positions.set(index-1, symbol);
    }

    private String format(){

        String line1 = positions.get(0) + "|" + positions.get(1) + "|" + positions.get(2) +"\n";
        String line2 = "-----------\n";
        String line3 = positions.get(3) + "|" + positions.get(4) + "|" + positions.get(5) +"\n";
        String line4 = "-----------\n";
        String line5 = positions.get(6) + "|" + positions.get(7) + "|" + positions.get(8);

        return line1 + line2 + line3 + line4 + line5;
    }

    public boolean isValid(int testIndex) {

        if(positions.get(testIndex-1) == "   "){
            return true;
        }
        else{
            return false;
        }
    }

    public boolean isFull() {

        boolean full = true;
        for(String cell: positions){
            if(cell.equals("   ")){
                full = false;
            }
        }
        return full;
    }

    public boolean threeInARowCheck() {
        return false;
    }
}
